home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / calc / help / list < prev    next >
Text File  |  1995-07-17  |  2KB  |  45 lines

  1. Using lists
  2.  
  3.     Lists are a sequence of values which are doubly linked so that
  4.     elements can be removed or inserted anywhere within the list.
  5.     The function 'list' creates a list with possible initial elements.
  6.     For example,
  7.  
  8.         x = list(4, 6, 7);
  9.  
  10.     creates a list in the variable x of three elements, in the order
  11.     4, 6, and 7.
  12.  
  13.     The 'push' and 'pop' functions insert or remove an element from
  14.     the beginning of the list.  The 'append' and 'remove' functions
  15.     insert or remove an element from the end of the list.  The 'insert'
  16.     and 'delete' functions insert or delete an element from the middle
  17.     (or ends) of a list.  The functions which insert elements return
  18.     the null value, but the functions which remove an element return
  19.     the element as their value.  The 'size' function returns the number
  20.     of elements in the list.
  21.  
  22.     Note that these functions manipulate the actual list argument,
  23.     instead of returning a new list.  Thus in the example:
  24.  
  25.         push(x, 9);
  26.  
  27.     x becomes a list of four elements, in the order 9, 4, 6, and 7.
  28.     Lists can be copied by assigning them to another variable.
  29.  
  30.     An arbitrary element of a linked list can be accessed by using the
  31.     double-bracket operator.  The beginning of the list has index 0.
  32.     Thus in the new list x above, the expression x[[0]] returns the
  33.     value of the first element of the list, which is 9.  Note that this
  34.     indexing does not remove elements from the list.
  35.  
  36.     Since lists are doubly linked in memory, random access to arbitrary
  37.     elements can be slow if the list is large.  However, for each list
  38.     a pointer is kept to the latest indexed element, thus relatively
  39.     sequential accesses to the elements in a list will not be slow.
  40.  
  41.     Lists can be searched for particular values by using the 'search'
  42.     and 'rsearch' functions.  They return the element number of the
  43.     found value (zero based), or null if the value does not exist in
  44.     the list.
  45.